{include file="public/header" /}
<style type="text/css">
    #container {
        min-width: 100px;
        min-height: 400px;
    }
</style>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=2AEBZ-YK23W-XISR6-ROOGV-VOLI7-46FFT"></script>

<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <form action="" method="post" class="layui-form layui-form-pane">
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">商家类型</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="type" lay-verify="required">
                                <option value="">商家类型</option>
                                {foreach $types as $k => $v}
                                <option value="{$k}" {if !empty($row.type) && $row.type==$k}selected{/if}>{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">经理派单类型/店面信息(选填)</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="ytypes" lay-verify="required" lay-filter="ytypes">
                                <option value="0">经理派单信息(选填)</option>
                                {foreach $ytypes as $k => $y}
                                <option value="{$k}" {if !empty($row.ytypes) && $row.ytypes==$k}selected{/if}>
                                    {$y}</option>
                                {/foreach}
                            </select>
                            <select name="ytypeslist" lay-verify="required" lay-filter="ytypeslist">
                                <option value="0">店面信息(选填)</option>
                                {foreach $ytypeslist as $k => $y}
                                <option value="{$k}" {if !empty($row.ytypeslist) && $row.ytypeslist==$k}selected{/if}>
                                    {$y}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">派单类型</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="ordertype" lay-filter="ordertype">
                                <option value="">派单类型</option>
                                {foreach $ordertype as $k => $y}
                                <option value="{$k}" {if !empty($row.ordertype) && $row.ordertype==$k}selected{/if}>
                                    {$y}</option>
                                {/foreach}
                            </select>
                            <p>安装和首次开业派单如无同时进行请在原选址或待开业订单上进行修改</p>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">是否置顶</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="istop" lay-verify="required">
                                <option value="1" {if !empty($row.ctype) && $row.ctype==1}selected{/if}>
                                    否</option>
                                <option value="2" {if !empty($row.ctype) && $row.ctype==2}selected{/if}>
                                    是</option>
                            </select>

                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">是否计入门店查询</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="ctype" lay-verify="required">
                                <option value="1" {if !empty($row.ctype) && $row.ctype==1}selected{/if}>
                                    计入门店查询</option>
                                <option value="2" {if !empty($row.ctype) && $row.ctype==2}selected{/if}>
                                    不计入门店查询</option>
                            </select>

                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">第1联系人</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md6">
                            <input type="text" id="name" name="name" 
                                autocomplete="off" class="layui-input" value="{$row.name|default=''}"
                                placeholder="请填写商家联系人姓名">
                        </div>
                        <div class="layui-col-md6">
                            <input type="text" id="phone" name="phone" autocomplete="off" class="layui-input"
                                value="{$row.phone|default=''}" placeholder="联系人电话">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">第2联系人</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md6">
                            <input type="text" id="name2" name="name2" autocomplete="off" class="layui-input"
                                value="{$row.name2|default=''}" placeholder="请填写商家联系人姓名">
                        </div>
                        <div class="layui-col-md6">
                            <input type="number" id="phone2" name="phone2" autocomplete="off" class="layui-input"
                                value="{$row.phone2|default=''}" placeholder="联系人电话">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">选址督导出发日期<span style="color: red;">(不填写日期表示待定)</span></div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="xtimessetting">
                                <option value="0">验证派单类型</option>
                                <option value="1">不验证派单类型</option>
                            </select>
                            <input type="text" id="test2" name="xtimes" autocomplete="off" class="layui-input"
                                value="{$row.xtimes|default=''}" placeholder="">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">开业日期</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <input type="text" id="test" name="times" autocomplete="off" class="layui-input"
                                value="{$row.times|default=''}" placeholder="">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">业务经理</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="yuid" lay-search="">
                                <option value="" {if empty($row.yuid) && $row.yuid==0}selected{/if}>业务经理</option>
                                {foreach $yewu as $y}
                                {if (empty($row.yuid) && $y.del == 1) || !empty($row.yuid)}
                                <option value="{$y.id}" {if !empty($row.yuid) && $row.yuid==$y.id}selected{/if}>
                                    {$y.account}{if $y.del != 1}(账号已删){/if}</option>
                                {/if}
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">报销</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <input type="radio" name="baoxiaosons" lay-filter="baoxiaosons" value="1" {if
                                empty($row.baoxiaosons) || $row.baoxiaosons==1}checked{/if} title="正常报销审核">
                            <input type="radio" name="baoxiaosons" lay-filter="baoxiaosons" value="2" {if
                                !empty($row.baoxiaosons) && $row.baoxiaosons==2}checked{/if} title="报销审批员审核">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">选址督导</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="duid" lay-search="">
                                <option value="" {if empty($row.duid) && $row.duid==0}selected{/if}>选址督导</option>
                                {foreach $dudao as $y}
                                {if (empty($row.duid) && $y.del == 1) || !empty($row.duid)}
                                <option value="{$y.id}" {if !empty($row.duid) && $row.duid==$y.id}selected{/if}>
                                    {$y.account}{if $y.del != 1}(账号已删){/if}</option>
                                {/if}
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">协选督导(协选不通知,重复同一协选只生效一次)</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <a class="layui-btn layui-btn-btn layui-btn-sm layui-btn-normal"
                                onclick="addtable2()">添加协选督导</a>
                            <table class="layui-table layui-form" style="border:1px solid #ccc;" id="table2"
                                lay-filter="table2">
                                <thead>
                                    <tr>
                                        <td>
                                            <div class="layui-table-cell">序号</div>
                                        </td>
                                        <td>
                                            <div class="layui-table-cell">协选督导</div>
                                        </td>
                                        <td>
                                            <div class="layui-table-cell">操作</div>
                                        </td>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $sqlist as $xk => $xv}
                                    <tr style="width:100px">
                                        <td>{$xk+1}</td>
                                        <td>
                                            <select name="xxlist[{$xk+1}]" lay-search="">
                                                <option value="">请选择协选督导</option>
                                                {foreach $dudao as $y}
                                                {if (empty($xv.user_id) && $y.del == 1) || !empty($xv.user_id)}
                                                <option value="{$y.id}" {if !empty($xv.user_id) &&
                                                    $xv.user_id==$y.id}selected{/if}>
                                                    {$y.account}{if $y.del != 1}(账号已删){/if}</option>
                                                {/if}
                                                {/foreach}
                                            </select>
                                        </td>
                                        <td><a class="layui-btn layui-btn-danger layui-btn-xs del2">删除</a></td>
                                    </tr>
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">售后经理</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="suid" lay-search="">
                                <option value="" {if empty($row.suid) && $row.suid==0}selected{/if}>售后经理</option>
                                {foreach $shouhou as $y}
                                {if (empty($row.suid) && $y.del == 1) || !empty($row.suid)}
                                <option value="{$y.id}" {if !empty($row.suid) && $row.suid==$y.id}selected{/if}>
                                    {$y.account}{if $y.del != 1}(账号已删){/if}</option>
                                {/if}
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">开业督导</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="kuid" lay-search="">
                                <option value="" {if empty($row.kuid) && $row.kuid==0}selected{/if}>开业督导</option>
                                {foreach $dudao as $y}
                                {if (empty($row.kuid) && $y.del == 1) || !empty($row.kuid)}
                                <option value="{$y.id}" {if !empty($row.kuid) && $row.kuid==$y.id}selected{/if}>
                                    {$y.account}{if $y.del != 1}(账号已删){/if}</option>
                                {/if}
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">尾款确认状态(请先查看是否需要审核，否则驳回将会还原){if
                        !empty($row.weikuancw)
                        && $row.weikuancw==3}<span style="font-weight: bold;">财务已确认全款，请谨慎修改</span>{/if}</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="weikuan" lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.weikuan) && $row.weikuan==1}selected{/if}>未回款</option>
                                <option value="2" {if !empty($row.weikuan) && $row.weikuan==2}selected{/if}>部分回款
                                </option>
                                <option value="3" {if !empty($row.weikuan) && $row.weikuan==3}selected{/if}>全部回款
                                </option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">装修确认状态</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="zhuangxiu" lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.zhuangxiu) && $row.zhuangxiu==1}selected{/if}>未装修
                                </option>
                                <option value="2" {if !empty($row.zhuangxiu) && $row.zhuangxiu==2}selected{/if}>装修中
                                </option>
                                <option value="3" {if !empty($row.zhuangxiu) && $row.zhuangxiu==3}selected{/if}>装修完毕
                                </option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">上货状态</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="shanghuo" lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.shanghuo) && $row.shanghuo==1}selected{/if}>未上货
                                </option>
                                <option value="2" {if !empty($row.shanghuo) && $row.shanghuo==2}selected{/if}>已上货
                                </option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">货架安装状态</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="huozhuang" lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.huozhuang) && $row.huozhuang==1}selected{/if}>未安装
                                </option>
                                <option value="2" {if !empty($row.huozhuang) && $row.huozhuang==2}selected{/if}>已安装
                                </option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">首单发货状态</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="isfirst" lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.isfirst) && $row.isfirst==1}selected{/if}>未发货</option>
                                <option value="2" {if !empty($row.isfirst) && $row.isfirst==2}selected{/if}>已发货</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">首单发货日期</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <input type="text" id="test3" name="firsttimes" autocomplete="off" class="layui-input"
                                value="{$row.firsttimes|default=''}" placeholder="">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">货架发货状态</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <select name="ishuo" lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.ishuo) && $row.ishuo==1}selected{/if}>未发货</option>
                                <option value="2" {if !empty($row.ishuo) && $row.ishuo==2}selected{/if}>已发货</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">派单区域(请严格按照省市区县(街道填写，方便查询))
                    </div>
                    <div class="layui-card-header" style="color: red;">第二区域和第一区域请用&符号分割，如:北京市北京市朝阳区&湖南省长沙市长沙县
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <textarea name="areas" class="layui-textarea">{$row.areas|default=''}</textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">选址派单说明
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <textarea name="xremark" class="layui-textarea">{$row.xremark|default=''}</textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">业务派单说明
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <textarea name="yremark" class="layui-textarea">{$row.yremark|default=''}</textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">售后派单说明
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <textarea name="sremark" class="layui-textarea">{$row.sremark|default=''}</textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">开业派单说明
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <textarea name="givermeark" class="layui-textarea">{$row.givermeark|default=''}</textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header" style="color:red;font-size: 20px;">店铺状态</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            {if isset($row['schedule']) && $row.schedule <= 0} <select name="status"
                                lay-verify="required" lay-filter="type">
                                <option value="1" {if !empty($row.status) && $row.status==1}selected{/if}>营业中</option>
                                <option value="2" {if !empty($row.status) && $row.status==2}selected{/if}>预备开业</option>
                                <option value="3" {if !empty($row.status) && $row.status==3}selected{/if}>可选店面</option>
                                <option value="4" {if !empty($row.status) && $row.status==4}selected{/if}>删除店面</option>
                                <option value="5" {if !empty($row.status) && $row.status==5}selected{/if}>已停业</option>
                                </select>
                                {else}
                                <select name="schedule" lay-verify="required" lay-filter="type">
                                    {foreach $schedule_nav as $k => $y}
                                    <option value="{$k}" {if !empty($row.schedule) && $row.schedule==$k}selected{/if}>
                                        {$y}</option>
                                    {/foreach}
                                </select>
                                <p style="color:red">
                                    对应原可选店面:指派选址、人员选址<br />
                                    对应原预备开业:售后处理、开业指派、预备开业<br />
                                    对应原营业中:确认开业、任务完结<br />
                                    删除店面:派单取消<br />
                                    此页面更改状态不会产生通知，请留意。
                                </p>
                                {/if}
                        </div>

                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">店铺地址信息(省市区根据定位自动填写)</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <input type="text" name="address" class="layui-input" placeholder="填写店铺街道及具体地址"
                                value="{$row.address|default=''}">
                        </div>
                    </div>
                </div>
                <div class="layui-card layui-form" lay-filter="component-form-element">
                    <div class="layui-card-header">地图地址</div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <input type="text" id="posaddress" name="posaddress" autocomplete="on" class="layui-input"
                                value="" placeholder="搜索列表如果有偏差，请手动选择较近位置再进行地图校准">
                        </div>
                        <div class="layui-col-md12" id="sousuo"></div>
                        <div id="container" class="layui-col-md12"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <input type="hidden" value="{$row.lat|default='0'}" name="lat">
                    <input type="hidden" value="{$row.lon|default='0'}" name="lon">
                    <input type="hidden" value="{$row.id|default=''}" name="id">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="addmessage">提交并通知</button>
                    <button class="layui-btn" lay-submit="" lay-filter="add">提交但不通知</button>
                    <p style="color:red;padding-top: 15px;">仅首次指派或督导变更情况下通知,任务状态变化但督导无变更情况下不通知</p>
                </div>
            </form>
        </div>
    </div>

    {include file="public/footer" /}
    <script src="/static/leyedit/Layui-KnifeZ/layui.all.js"></script>
    <script src="/static/leyedit/ace/ace.js"></script>
    <script>
        function addtable2() {
            var i = $('#table2 tbody tr').length;
            var check = '<select lay-search="" name="xxlist[' + (i + 1) + ']" lay-verify="required"><option value="">请选择协选督导</option>';
            var json = {$dudao|raw};
        $.each(json, function (m, obj) {
            check += '<option  value="' + obj.id + '">' + obj.account + '</option>';
        });
        check += '</select>';
        //你要添加的html
        var html = '<tr ><td>' + (i + 1) + '</td><td>' + check + '</td><td><a class="layui-btn layui-btn-danger layui-btn-xs del2">删除</a></td></tr>';
        $(html).appendTo($('#table2 tbody:last'));
        layui.use(['form'], function () {
            $ = layui.jquery;
            var form = layui.form;
            form.render();
        });
        };
        $('body').on('click', '.del2', function () {
            $(this).closest('tr').remove();
        });
        layui.use(['layer', 'jquery', 'form', 'laydate'], function () {
            $ = layui.jquery;
            var form = layui.form
                , laydate = layui.laydate
                , layer = layui.layer;
            //腾讯地图部分
            var position = document.getElementById("position");
            var center = new qq.maps.LatLng("{$row.lat|default='28.218897'}", "{$row.lon|default='113.093453'}");//设置中心点坐标
            //初始化地图
            var map = new qq.maps.Map("container", {
                center: center,
                zoom: 17,
                viewmode: '3D',
                pitch: 50
            });
            //初始化infoWindow
            var infoWindow = new qq.maps.InfoWindow({
                map: map
            });
            infoWindow.open();
            infoWindow.setContent("{$row.name|default=''}");
            infoWindow.setPosition(map.getCenter());
            //点击事件
            qq.maps.event.addListener(map, 'click', function (evt) {
                var shopname = $("input[name='title']").val();
                var lat = evt.latLng.getLat().toFixed(8);
                var lng = evt.latLng.getLng().toFixed(8);
                var center = new qq.maps.LatLng(lat, lng);//设置中心点坐标
                infoWindow.setPosition(center);
                infoWindow.setContent(shopname);
                $("input[name='lat']").val(lat);
                $("input[name='lon']").val(lng);
            });
            //输入框的值改变时触发
            $("#posaddress").on("input", function (e) {
                var title = e.delegateTarget.value;
                $.ajax({
                    type: 'get',
                    url: '/base/getaddress',
                    data: { keyword: title },
                    success: function (res) {
                        if (res.code == 0) {
                            str = '';
                            $.each(res.data, function (i, obj) {
                                if (i < 5) {
                                    str += '<input lay-filter="getsou" type="radio" name="suosuo" value="' + obj.location.lat + ',' + obj.location.lng + '" title="' + obj.title + '[' + obj.address + ']' + '"><br/>';
                                }
                            });
                            $('#sousuo').html(str);
                            form.render();
                        }
                    }
                });
                return false;
            });
            //监听专业修改信息
            form.on('select(ytypes)', function (data) {
                console.log(data.value);
                if (data.value == 3 || data.value == 0) {
                    console.log(data.value);
                    $('select[name="ytypeslist"]').val('');
                    form.render();
                }
            });
            //监听专业修改信息
            form.on('radio(getsou)', function (data) {
                console.log(data);
                var location = data.value.split(","); //字符分割 
                $("input[name='lat']").val(location[0]);
                $("input[name='lon']").val(location[1]);
                var shopname = $("input[name='name']").val();
                var center = new qq.maps.LatLng(location[0], location[1]);//设置中心点坐标
                map.setCenter(center);
                infoWindow.setPosition(center);
                infoWindow.setContent(shopname);
            });
            laydate.render({
                elem: '#test'
                , type: 'date'
            });
            laydate.render({
                elem: '#test2'
                , type: 'date'
            });
            laydate.render({
                elem: '#test3'
                , type: 'date'
            });
            //监听省份选择
            form.on('select(province)', function (data) {
                if (!data.value) {
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 2 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="0">请选择城市</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.name;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="city"]').html(str);
                            $('select[name="area"]').html('');
                            $('select[name="street"]').html('');
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
            //监听城市选择
            form.on('select(city)', function (data) {
                if (!data.value) {
                    return false;
                }
                //选中状态发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 3 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="0">请选择区域</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.name;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="area"]').html(str);
                            $('select[name="street"]').html('');
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });

                return false;
            });
            //监听提交
            form.on('submit(add)', function (data) {
                $.ajax({
                    'type': 'post',
                    data: data.field,
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
            //监听提交并通知
            form.on('submit(addmessage)', function (data) {
                data.field.message = 2;
                $.ajax({
                    'type': 'post',
                    data: data.field,
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>

</body>

</html>